Skip to content

Skip the class-transformer response pass on the v6 client controller - #3395

Merged
danoswaltCL merged 1 commit into
devfrom
wip/client-controller-skip-response-transform
Oct 26, 2026
Merged

danoswaltCL merged 1 commit into
devfrom
wip/client-controller-skip-response-transform

Conversation

@danoswaltCL

Copy link
Copy Markdown
Collaborator

class-transformer is adding a "transform" on every request and response (classTransformer: true in app.ts). this is to apply decorators, which we use all over the place for requests, but responses in client controller don't use any decorators that actually change any outgoing response, so it's just making a copy.

this is probably pretty negligible for most responses, but it isn't for assign responses, especially for express-mode within-subjects responses. it causes a small but noticeable wait, which is made much worse during bursts where everything waiting on the thread inherits every wait ahead of it.

This turns off the response transform for the whole v6 client controller. Request bodies are unaffected: they're still transformed into validator classes and validated. The JSON sent is unchanged; the new controller tests check this over HTTP for /assign, /featureflag, /useraliases and /reward. Any route that later needs the response transform can opt back in with { transformResponse: true }.

Every /v6 route returns plain data (literals, raw rows, string arrays, or
objects already built in the response shape), so routing-controllers'
instanceToPlain only deep-copied each response before JSON.stringify. It is
now off for the whole client controller via @jsoncontroller options; a route
can opt back in with { transformResponse: true }. Request bodies are still
transformed into their validator classes and validated.

Adds the first ExperimentClientController tests: over HTTP, /assign,
/featureflag, /useraliases and /reward return a class instance whose
@exclude'd field survives only if the transform is skipped, and an invalid
/assign body is still rejected before reaching the service.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 26, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review supports the narrowly scoped change with no blocking findings; tests were not executed.

No open issues 🎉

What changed in this PR

Removes the response-side class-transformer pass from the v6 client controller to reduce serialization overhead, particularly for large assignment responses. Request transformation and validation remain enabled.

Changes:

  • Disables response transformation controller-wide, with per-route opt-in available.
  • Adds HTTP tests verifying transformation is skipped for four endpoints and invalid assignment requests are still rejected.
File Description
packages/​backend/​test/​unit/​controllers/​ExperimentClientController.test.ts Adds response-transformation and request-validation regression tests.
packages/​backend/​src/​api/​controllers/​ExperimentClientController.v6.ts Disables response transformation and documents the scope and opt-in option.

Review effort: Balanced

@danoswaltCL
danoswaltCL requested a review from bcb37 October 26, 2026 18:32
@danoswaltCL
danoswaltCL merged commit 86899e1 into dev Oct 26, 2026
7 checks passed
@danoswaltCL
danoswaltCL deleted the wip/client-controller-skip-response-transform branch October 26, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants